﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PresentationService.Models;
using System.ServiceModel;
using System.Web.Http.Tracing;

namespace PresentationService.Controllers
{
    public class ArchitectureSummaryController : ApiController
    {
        // GET: api/ArchitectureSummary
        public IEnumerable<DesignPatternModel> Get()
        {
            Configuration.Services.GetTraceWriter().Info(Request, "ArchitectureSummaryController", "Get the list of ....");


            BasicHttpBinding myBinding = new BasicHttpBinding();
            myBinding.Security.Mode = BasicHttpSecurityMode.None;

            EndpointAddress myEndpoint = new EndpointAddress("http://localhost:62714/ArchitectureService.svc");

            ChannelFactory<ServicesInterfaces.IArchitectureService> mychannel = new System.ServiceModel.ChannelFactory<ServicesInterfaces.IArchitectureService>(myBinding, myEndpoint);

            ServicesInterfaces.IArchitectureService client = mychannel.CreateChannel();

            List<DesignPatternModel> results = new List<DesignPatternModel>();
            client.GetAllDesignPatterns().ForEach(d =>
            {
                results.Add(new DesignPatternModel()
                {
                    Name = d.Name
                });
            });

            return (IEnumerable<DesignPatternModel>)results;
        }

        // GET: api/ArchitectureSummary/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/ArchitectureSummary
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/ArchitectureSummary/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/ArchitectureSummary/5
        public void Delete(int id)
        {
        }
    }
}
